#pragma once

#include <JuceHeader.h>
#include "chess.h"

class MainComponent  : public juce::Component,public juce::Button::Listener
{
public:
    //==============================================================================
    MainComponent();
    ~MainComponent() override;

    //==============================================================================
    void paint (juce::Graphics&) override;
    void resized() override;



private:

    juce::String StartText ;
    juce::String EndText;
    juce::String SettingText ;
    juce::String AboutText ;

    juce::Image board;
    juce::Image white;
    juce::Image black;

    juce::TextButton StartButton;
    juce::TextButton SettingButton;
    juce::TextButton AboutButton;

    virtual void buttonClicked (juce::Button*);
    virtual void mouseDown (const juce::MouseEvent& event);

    void StartGame();
    void SetBoard(const std::string& str);
    void ShowSetting();
    void ShowAbout();


    int state = 0;      // 0:未开始 1:已开始 2:已结束
    int type = 0;       // 先手 0:人 1:电脑
    int turn = 0;       // 当前是先手还是后手 0:先手 1:后手
    int difficulty = 3; // 难度 0:简单 1:一般 2:困难 3:地狱
    Gomoku* game = nullptr;

    //
    int BoardOffset = 23;
    int BoardGrid = 35;




    //
    juce::StringArray difficultyItems;
    juce::StringArray xian ;

    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainComponent)
};
